<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import musicAlbum from '@/api/music/musicAlbum'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()



const switchStatus = (statusValue, id, statusName) => {
  musicAlbum.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'music_album',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: musicAlbum.getList,
  recycleApi: musicAlbum.getRecycleList,
  add: {
    show: true,
    api: musicAlbum.save,
    auth: ['music:album:save']
  },
  edit: {
    show: true,
    api: musicAlbum.update,
    auth: ['music:album:update']
  },
  delete: {
    show: true,
    api: musicAlbum.deletes,
    auth: ['music:album:delete'],
    realApi: musicAlbum.realDeletes,
    realAuth: ['music:album:realDeletes']
  },
  recovery: {
    show: true,
    api: musicAlbum.recoverys,
    auth: ['music:album:recovery']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "专辑名称",
    dataIndex: "title",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入专辑名称"
    }
  },
  {
    title: "歌手/艺术家 ID",
    dataIndex: "artist_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "发行日期",
    dataIndex: "release_date",
    formType: "date",
    search: true,
    showTime: false
  },
  {
    title: "封面图片 URL",
    dataIndex: "cover_art",
    formType: "input",
    search: true
  },
  {
    title: "简介",
    dataIndex: "desc",
    formType: "editor",
    hide: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'music:album' } </script>